package net.runman.event;

import net.runman.model.TUsers;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;

@Component
@EnableAsync
public class UserSaveListener implements ApplicationListener<UserSaveEvent> {

	private static final Logger logger = LoggerFactory.getLogger(UserSaveListener.class);

	@Async
	@Override
	public void onApplicationEvent(UserSaveEvent event) {
		if (!(event.getSource() instanceof TUsers)) {
			return;
		}
		logger.error(Thread.currentThread().getName() + "\t" + event.getClass() + ":\t" + event.getSource());
	}

//	新线程需要同时
//	@EnableAsync + @Async
}
